home *** CD-ROM | disk | FTP | other *** search
/ Atari Forever 4 / Atari Forever 4.zip / Atari Forever 4.iso / SERIE_SP / SP_002 / APPLE_II / CONVERT.C < prev    next >
C/C++ Source or Header  |  1998-03-14  |  2KB  |  74 lines

  1.  
  2. /***********************************************************************
  3. *                                                                      *
  4. * CONVERT.C - by Darek Mihocka  December 14, 1986                      *
  5. *                                                                      *
  6. * This program converts a Apple monitor hex dump into a Atari DOS 2.0  *
  7. * formatted file for use with the Apple Emulator.                      *
  8. *                                                                      *
  9. * Specify a source file which contains a hex dump and a destination    *
  10. * file ending in .BIN which will be the binary file.                   *
  11. *                                                                      *
  12. * Note: binary file generated should be loaded and resaved with the    *
  13. *       emulator to adjust file length.                                *
  14. *                                                                      *
  15. ***********************************************************************/
  16.  
  17. #include <stdio.h>
  18. #include <osbind.h>
  19. #include <string.h>
  20.  
  21. main (argc,argv)
  22. int argc ;
  23. char *argv[] ;
  24.  {
  25.  
  26.   FILE *source, *dest ;
  27.   unsigned int hex0, hex1, hex2, hex3, hex4, hex5, hex6, hex7 ;
  28.   unsigned int addr ;
  29.   int error ;
  30.  
  31.   printf ("now converting ... %s to %s\n",argv[1],argv[2]) ;
  32.   source = fopen (argv[1],"r") ;
  33.   dest = fopen (argv[2],"bw") ;
  34.  
  35.   error = fscanf (source,
  36.            " %x- %x %x %x %x %x %x %x %x ",
  37.           &addr, &hex0, &hex1, &hex2, &hex3, &hex4, &hex5, &hex6, &hex7) ;
  38.  
  39.  
  40.   putc (255,dest) ;     /* DOS 2.0 header */
  41.   putc (255,dest) ;
  42.   putc (addr&255,dest) ;
  43.   putc (addr>>8,dest) ;
  44.   putc (255,dest) ;
  45.   putc (255,dest) ;
  46.  
  47.   do {
  48.  
  49.        if (error==9) printf (" %4x",addr) ;
  50.        else printf ("ERROR!!!!\n %4x",addr) ;
  51.  
  52.        putc ((char)hex0,dest) ;
  53.        putc ((char)hex1,dest) ;
  54.        putc ((char)hex2,dest) ;
  55.        putc ((char)hex3,dest) ;
  56.        putc ((char)hex4,dest) ;
  57.        putc ((char)hex5,dest) ;
  58.        putc ((char)hex6,dest) ;
  59.        putc ((char)hex7,dest) ;
  60.  
  61.        error = fscanf (source,
  62.            " %x- %x %x %x %x %x %x %x %x ",
  63.           &addr, &hex0, &hex1, &hex2, &hex3, &hex4, &hex5, &hex6, &hex7) ;
  64.  
  65.    } while (error==9 && error !=-1 ) ;
  66.  
  67.   fflush (dest) ;
  68.  
  69.   fclose (source) ;
  70.   fclose (dest) ;
  71. }
  72.  
  73.  
  74.